home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Binary.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  2.0 KB  |  54 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import symjava.sql.SQLException;
  7.  
  8. public class Binary extends BinaryField {
  9.    Binary() {
  10.    }
  11.  
  12.    int getType() {
  13.       return 70;
  14.    }
  15.  
  16.    void read(DataInputStream is) throws SQLException, IOException, ErrorException {
  17.       super.read(is);
  18.       if (!super._null) {
  19.          ServerObject obj = (ServerObject)NetClass.getNextObject(is);
  20.          if (obj.getType() == 51) {
  21.             super._binData = ((NetData)obj).getBytes();
  22.          } else {
  23.             ((ServerObject)this).onObjectError(obj);
  24.          }
  25.       }
  26.  
  27.       ServerObject obj = (ServerObject)NetClass.getNextObject(is);
  28.       if (obj.getType() != 50) {
  29.          ((ServerObject)this).onObjectError(obj);
  30.       }
  31.  
  32.    }
  33.  
  34.    void write(DataOutputStream os) throws IOException {
  35.       super.write(os);
  36.       NetData d = new NetData(super._binData);
  37.       d.write(os);
  38.       EOT eot = new EOT();
  39.       eot.write(os);
  40.    }
  41.  
  42.    public int getSQLType() {
  43.       return -2;
  44.    }
  45.  
  46.    public Object getObject() throws SQLException {
  47.       return ((BinaryField)this).getBytes();
  48.    }
  49.  
  50.    public void setObject(Object obj) throws SQLException {
  51.       ((BinaryField)this).setBytes((byte[])obj);
  52.    }
  53. }
  54.